<?php

/**
 * This is the model class for table "school_history".
 *
 * The followings are the available columns in table 'school_history':
 * @property integer $id
 * @property integer $school_id
 * @property string $year
 * @property integer $school_status
 * @property string $membership_sought
 * @property string $monthly_tuition
 * @property integer $total_students
 * @property integer $ministries_gift
 * @property integer $total_payment
 */
class SchoolHistory extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return SchoolHistory the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'school_history';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('school_id, year, school_status, membership_sought, monthly_tuition, total_students, ministries_gift, total_payment', 'safe'),
			// array('school_id, school_status, total_students, ministries_gift, total_payment', 'numerical', 'integerOnly'=>true),
			// array('year', 'length', 'max'=>10),
			// array('membership_sought, monthly_tuition', 'length', 'max'=>500),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, school_id, year, school_status, membership_sought, monthly_tuition, total_students, ministries_gift, total_payment', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'school_id' => 'School',
			'year' => 'Year',
			'school_status' => 'School Status',
			'membership_sought' => 'Membership Sought',
			'monthly_tuition' => 'Monthly Tuition',
			'total_students' => 'Total Students',
			'ministries_gift' => 'Ministries Gift',
			'total_payment' => 'Total Payment',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('school_id',$this->school_id);
		$criteria->compare('year',$this->year,true);
		$criteria->compare('school_status',$this->school_status);
		$criteria->compare('membership_sought',$this->membership_sought,true);
		$criteria->compare('monthly_tuition',$this->monthly_tuition,true);
		$criteria->compare('total_students',$this->total_students);
		$criteria->compare('ministries_gift',$this->ministries_gift);
		$criteria->compare('total_payment',$this->total_payment);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}